/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package it.unisannio.rcost.callgraphanalyzer.provider;

import it.unisannio.rcost.callgraphanalyzer.util.CallGraphAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class CallGraphItemProviderAdapterFactory extends CallGraphAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CallGraphItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Graph} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GraphItemProvider graphItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Graph}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createGraphAdapter() {
		if (graphItemProvider == null) {
			graphItemProvider = new GraphItemProvider(this);
		}

		return graphItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Package} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PackageItemProvider packageItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Package}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPackageAdapter() {
		if (packageItemProvider == null) {
			packageItemProvider = new PackageItemProvider(this);
		}

		return packageItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.ExplicitCall} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExplicitCallItemProvider explicitCallItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.ExplicitCall}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExplicitCallAdapter() {
		if (explicitCallItemProvider == null) {
			explicitCallItemProvider = new ExplicitCallItemProvider(this);
		}

		return explicitCallItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Class} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClassItemProvider classItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Class}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createClassAdapter() {
		if (classItemProvider == null) {
			classItemProvider = new ClassItemProvider(this);
		}

		return classItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Field} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FieldItemProvider fieldItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Field}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createFieldAdapter() {
		if (fieldItemProvider == null) {
			fieldItemProvider = new FieldItemProvider(this);
		}

		return fieldItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Method} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MethodItemProvider methodItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Method}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createMethodAdapter() {
		if (methodItemProvider == null) {
			methodItemProvider = new MethodItemProvider(this);
		}

		return methodItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Pointcut} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PointcutItemProvider pointcutItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Pointcut}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPointcutAdapter() {
		if (pointcutItemProvider == null) {
			pointcutItemProvider = new PointcutItemProvider(this);
		}

		return pointcutItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Advice} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AdviceItemProvider adviceItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Advice}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAdviceAdapter() {
		if (adviceItemProvider == null) {
			adviceItemProvider = new AdviceItemProvider(this);
		}

		return adviceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Aspect} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AspectItemProvider aspectItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Aspect}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAspectAdapter() {
		if (aspectItemProvider == null) {
			aspectItemProvider = new AspectItemProvider(this);
		}

		return aspectItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Interface} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InterfaceItemProvider interfaceItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Interface}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInterfaceAdapter() {
		if (interfaceItemProvider == null) {
			interfaceItemProvider = new InterfaceItemProvider(this);
		}

		return interfaceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.ImplicitCall} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ImplicitCallItemProvider implicitCallItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.ImplicitCall}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createImplicitCallAdapter() {
		if (implicitCallItemProvider == null) {
			implicitCallItemProvider = new ImplicitCallItemProvider(this);
		}

		return implicitCallItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Association} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AssociationItemProvider associationItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Association}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAssociationAdapter() {
		if (associationItemProvider == null) {
			associationItemProvider = new AssociationItemProvider(this);
		}

		return associationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Implementation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ImplementationItemProvider implementationItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Implementation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createImplementationAdapter() {
		if (implementationItemProvider == null) {
			implementationItemProvider = new ImplementationItemProvider(this);
		}

		return implementationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Dependence} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DependenceItemProvider dependenceItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Dependence}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDependenceAdapter() {
		if (dependenceItemProvider == null) {
			dependenceItemProvider = new DependenceItemProvider(this);
		}

		return dependenceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Extension} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExtensionItemProvider extensionItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Extension}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExtensionAdapter() {
		if (extensionItemProvider == null) {
			extensionItemProvider = new ExtensionItemProvider(this);
		}

		return extensionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.Project} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProjectItemProvider projectItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.Project}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createProjectAdapter() {
		if (projectItemProvider == null) {
			projectItemProvider = new ProjectItemProvider(this);
		}

		return projectItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.ImplicitCallDecorator} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ImplicitCallDecoratorItemProvider implicitCallDecoratorItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.ImplicitCallDecorator}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createImplicitCallDecoratorAdapter() {
		if (implicitCallDecoratorItemProvider == null) {
			implicitCallDecoratorItemProvider = new ImplicitCallDecoratorItemProvider(this);
		}

		return implicitCallDecoratorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.ExplicitCallDecorator} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExplicitCallDecoratorItemProvider explicitCallDecoratorItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.ExplicitCallDecorator}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createExplicitCallDecoratorAdapter() {
		if (explicitCallDecoratorItemProvider == null) {
			explicitCallDecoratorItemProvider = new ExplicitCallDecoratorItemProvider(this);
		}

		return explicitCallDecoratorItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link it.unisannio.rcost.callgraphanalyzer.DependenceDecorator} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DependenceDecoratorItemProvider dependenceDecoratorItemProvider;

	/**
	 * This creates an adapter for a {@link it.unisannio.rcost.callgraphanalyzer.DependenceDecorator}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDependenceDecoratorAdapter() {
		if (dependenceDecoratorItemProvider == null) {
			dependenceDecoratorItemProvider = new DependenceDecoratorItemProvider(this);
		}

		return dependenceDecoratorItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (graphItemProvider != null) graphItemProvider.dispose();
		if (packageItemProvider != null) packageItemProvider.dispose();
		if (explicitCallItemProvider != null) explicitCallItemProvider.dispose();
		if (classItemProvider != null) classItemProvider.dispose();
		if (fieldItemProvider != null) fieldItemProvider.dispose();
		if (methodItemProvider != null) methodItemProvider.dispose();
		if (pointcutItemProvider != null) pointcutItemProvider.dispose();
		if (adviceItemProvider != null) adviceItemProvider.dispose();
		if (aspectItemProvider != null) aspectItemProvider.dispose();
		if (interfaceItemProvider != null) interfaceItemProvider.dispose();
		if (implicitCallItemProvider != null) implicitCallItemProvider.dispose();
		if (associationItemProvider != null) associationItemProvider.dispose();
		if (implementationItemProvider != null) implementationItemProvider.dispose();
		if (dependenceItemProvider != null) dependenceItemProvider.dispose();
		if (extensionItemProvider != null) extensionItemProvider.dispose();
		if (projectItemProvider != null) projectItemProvider.dispose();
		if (implicitCallDecoratorItemProvider != null) implicitCallDecoratorItemProvider.dispose();
		if (explicitCallDecoratorItemProvider != null) explicitCallDecoratorItemProvider.dispose();
		if (dependenceDecoratorItemProvider != null) dependenceDecoratorItemProvider.dispose();
	}

}
